Fix drag selection stopping when scrolling beyond visible items#735
Merged
Conversation
Co-authored-by: AlexV525 <15884415+AlexV525@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix dragging selection issue on second page
Fix drag selection stopping when scrolling beyond visible items
Dec 7, 2025
Member
|
@copilot When the drag gesture starts, the following assertion thrown: |
… controller Co-authored-by: AlexV525 <15884415+AlexV525@users.noreply.github.com>
Contributor
Author
... Fixed in commit 92b3372. The issue was that the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Plan: Fix drag-to-select stopping when scrolling to second page
Problem Analysis
SliverChildBuilderDelegate, only working for mounted itemsSolution Approach
AssetGridDragSelectionCoordinatorto calculate target indices from global positionsassetsGridBuilderto use a single gesture detector wrapper instead of per-item detectorsImplementation Steps
Changes Made
1.
asset_grid_drag_selection_coordinator.dart_calculateIndexFromPosition()method (lines 56-144) to calculate asset index from global position coordinatesonSelectionStart()to:BoxConstraintsinstead ofindexandassetScrollableStatefromgridScrollController.position.context.notificationContextinstead ofScrollable.maybeOf(context)_checkScrollableStatePresent()method as it's no longer neededonSelectionUpdate()to use the shared_calculateIndexFromPosition()method2.
asset_picker_builder_delegate.dartCustomScrollViewwith a singleGestureDetector(lines 1498-1568)sliverGridbuilderBug Fix (Latest Commit)
Issue: Assertion failure when drag gesture starts because
Scrollable.maybeOf(context)returns nullcontextpassed to gesture handlers was from outside theCustomScrollView, so no Scrollable ancestor was foundScrollableStatedirectly from theScrollController's position context instead of relying on BuildContextOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.